var mysql =require ('mysql');
var connection=mysql.createConnection({
    host :'127.0.0.1',
    user :'root',
    password:'root',
    database:'gillian'

});
connection.connect();

connection.query(`select count(*) from user where sex='男'`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})

connection.query(`select count(*) from user where sex='女'`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})
connection.query(`select count(*) from user`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})
connection.query(`SELECT * FROM USER where YEAR<18`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})
connection.query(`SELECT * FROM USER where YEAR BETWEEN 18 AND 45`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})
connection.query(`SELECT * FROM USER where YEAR>45`,(error,result)=>{
    if(error) throw error;
    console.log(result);
})
let page = 2;

let pageSize = 2;

let sql = "select * from user limit " + (page - 1) * pageSize + "," + pageSize;
connection.query(sql, (err, data) => {
    console.log(data);
});

connection.end();